package rpc.test.spring.annotation.provider.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import rpc.provider.spring.RpcSpringServer;

/**
 * @version 1.0.0
 * @description 基于注解的配置类
 */
@Configuration
@ComponentScan(value = {"rpc.test"})
@PropertySource(value = {"classpath:rpc.properties"})
public class SpringAnnotationProviderConfig {


    @Value("${server.enableResultCache}")
    private boolean enableResultCache;


    @Value("${server.corePoolSize}")
    private int corePoolSize;

    @Value("${server.maximumPoolSize}")
    private int maximumPoolSize;


    @Value("${registry.address}")
    private String registryAddress;

    @Value("${registry.type}")
    private String registryType;

    @Value("${registry.loadbalance.type}")
    private String registryLoadbalanceType;

    @Value("${server.address}")
    private String serverAddress;

    @Value("${reflect.type}")
    private String reflectType;

    @Value("${server.heartbeatInterval}")
    private int heartbeatInterval;

    @Value("${server.scanNotActiveChannelInterval}")
    private int scanNotActiveChannelInterval;

    @Value("${server.registry.address}")
    private String serverRegistryAddress;

    @Value("${server.resultCacheExpire}")
    private int resultCacheExpire;

    @Value("${server.flowType}")
    private String flowType;



    @Bean
    public RpcSpringServer rpcSpringServer(){
        return new RpcSpringServer(serverAddress, serverRegistryAddress, registryAddress, registryType, registryLoadbalanceType, reflectType, heartbeatInterval, scanNotActiveChannelInterval, enableResultCache, resultCacheExpire, corePoolSize, maximumPoolSize,flowType, 1000, "strategy_default", true, "counter", 100, 1000, "fallback", true, "counter", 100, 1000,"print");
    }
}

